﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter2.Section3
{
    public class Example02
    {
        public Example02()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double> f
                = new V.Function.ToLastType<double[], double>(func);
            double[] x = new Double[2];
            x[0] = 1.0;
            x[1] = 6.0;
            V.PartialDerivative obj = new V.PartialDerivative(f, x);

            obj.WithRespectTo = 0;
            obj.Compute();
            result += obj.Result.ToString() + "\r\n";

            obj.WithRespectTo = 1;
            obj.Compute();
            result += obj.Result.ToString() + "\r\n";

            result += (-x[1] * Math.Sin(x[0] * x[1]) + Math.Cos(x[1])).ToString() + "\r\n";
            result += (-x[0] * Math.Sin(x[0] * x[1]) - x[0]*Math.Sin(x[1])).ToString() + "\r\n";
        }
        private double func(double[] x)
        {
            return Math.Cos(x[0] * x[1]) + x[0] * Math.Cos(x[1]);
        }
    }
}
/* 
2.63666327584366
0.558830996399168
2.63666327584392
0.558830996397852
*/

